package com.itheima.d7_interface_demo;



import java.util.ArrayList;

public class OperatorOne implements StudentOperator {
//重写学生信息方法
    @Override
    public void PrintAll(ArrayList<Student> stus) {
        System.out.println("------------打印全部学生信息---------------");
        for (int i = 0; i < stus.size(); i++) {
            Student student = stus.get(i);
            System.out.println(student.getName() + " "+ student.getSex() + " " + student.getScore());
        }
        System.out.println("-----------------------------------------");
    }
//重写学生平均成绩方法
    @Override
    public void PrintAvg(ArrayList<Student> stus) {
        System.out.println("-------------打印学生平均成绩---------------");
        double avg = 0.0;
        for (int i = 0; i < stus.size(); i++) {
            Student student = stus.get(i);
            avg += student.getScore();
        }
        System.out.println("平均成绩为：" + avg / stus.size());
    }
}
